import { Message, Notification } from 'element-ui'

export function $message (args) {
  Message({
    showClose: true,
    type: args.type,
    message: args.message
  })
}

export function $notify (args) {
  Notification({
    title: '提示',
    showClose: true,
    type: args.type,
    message: args.message,
    duration: args.duration || 4500,
    position: args.position || 'bottom-right'
  })
}

// 病案相关提示确认框
export function $msgboxbase (args = { type: 'warning', msg: '', $this: null }) {
  const $this = args.$this
  const h = $this.$createElement
  const colors = {
    error: '#F56C6C',
    success: '#67C23A',
    warning: '#E6A23C'
  }
  const type = args.type
  const msg = args.msg
  const length = args.length // 批量操作时需要传length
  return $this.$msgbox({
    title: '提示',
    message: h('p', null, [
      h('span', null, '此操作将'),
      h('span', { style: 'color: ' + colors[type] + '; font-weight: bold' }, '「' + msg + ((length && length > 0) ? length + '条' : '') + '」'),
      h('span', null, ((length && length > 0) ? '' : '该') + '病案信息，是否继续？')
    ]),
    showCancelButton: true,
    confirmButtonText: '确 认',
    cancelButtonText: '取 消',
    type
  })
}
